<template>

	<view class="main">
		<u-navbar :fixed="true" title="收费记录" @rightClick="rightClick" :autoBack="true"></u-navbar>

		<view class="bit">

			<view class="row_a_c ">

				<uni-data-select placeholder="选择排序方式" v-model="sort_type" :localdata="range" @change="changeqx"></uni-data-select>

				<image v-if="sort_way==2" class="xltb" src="/static/images/sltb.png" @click="pxxx(1)"></image>
				<image v-else class="xltb" src="/static/images/xltb.png" @click="pxxx(2)"></image>

			</view>



		</view>



		<z-paging ref="paging" v-model="ChargeRecordListData" @query="queryList" usePageScroll>
			<view class=" column_c">
				<view class="card-content" v-for="(item, index) in ChargeRecordListData" :key="index">
					<view @click="toUrl(item.id)">
						<view class="row_a_c space-between">
							<text class="clinic">就诊时间：{{item.created_at}}</text>
							<text class="status success center">{{item.payment_way}}</text>
						</view>
						<view class="appointment-info">
							<view class="name">就诊项目：{{item.territory.name}}</view>
							<view class="time">消费门店：{{item.store.name}}</view>
							<view class="time">金额合计：￥{{item.amount}}</view>
						</view>
					</view>
				</view>
			</view>

		</z-paging>


	</view>

</template>

<script>
	import api_charge from '@/api/charge.js';
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin';


	export default {


		mixins: [ZPMixin],

		async onShow() {
			// this.getChargeRecordListFuc();
		},
		data() {
			return {
				sort_type: null, //排序类型 1消费时间 2消费金额
				sort_way: 1, //排序方式 1倒序 2升序
				range: [
					{ value: 1, text: "消费时间" },
					{ value: 2, text: "消费金额" },
				],
				ChargeRecordListData: [],
			};
		},
		methods: {

			async queryList(pageNo, pageSize) {

				const per = {
					no_page: pageNo,
					page_size: pageSize,
				}
				if (this.sort_type) {
					per.sort_type = this.sort_type
				}

				if (this.sort_way) {
					per.sort_way = this.sort_way
				}

				const res = await api_charge.getChargeRecordList(per);
				if (res.code == 1) {
					this.$refs.paging.complete(res.data.list);
				} else {
					this.$refs.paging.complete(false);
				}

			},

			pxxx(type) {
				this.sort_way = type;
				this.$refs.paging.reload();
			},

			changeqx() {
				this.sort_way = 1;
				this.$refs.paging.reload();
			},

			//获取收费列表
			// async getChargeRecordListFuc() {
			// 	var per = {
			// 		no_page: 1,
			// 		page_size: 10,
			// 	}

			// 	const res = await api_charge.getChargeRecordList(per);
			// 	if (res.code == 1) {
			// 		this.ChargeRecordListData = res.data.list
			// 	} else {
			// 		this.$util.msg(res.message);
			// 		return;
			// 	}
			// },


			toUrl(id) {
				uni.navigateTo({
					url: `/pages/zxhd/orderinfo?id=${id}`
				});
			},

		}
	};
</script>

<style scoped lang="scss">
	::v-deep .uni-select {
		width: 220rpx;
		background-color: #FAFAFA;
		border-radius: 10rpx;
		border: 0rpx solid #e5e5e5;
		border-bottom: solid 0rpx #e5e5e5;
	}

	.main {
		background: #FAFAFA;
		height: 100vh;

		// padding: 32rpx;
	}

	.bit {
		padding: 32rpx;
		margin-top: 180rpx;
	}

	.but {

		width: 290rpx;
		height: 60rpx;
		background: #FFFFFF;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		padding: 0 30rpx;
	}

	.time {
		font-weight: 400;
		font-size: 28rpx;
		color: #7F7F7F;
	}

	.xltb {
		width: 32rpx;
		height: 32rpx;
	}


	.container {
		padding: 0;
	}

	.card {
		background-color: #fff;
		border-radius: 8px;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		margin-bottom: 20px;
	}

	.card-header {
		display: flex;
		justify-content: space-between;
		padding: 10px;
		border-bottom: 1px solid #f0f0f0;
	}

	.status {
		width: 92rpx;
		height: 32rpx;
		background: #1FA194;
		border-radius: 4rpx 4rpx 4rpx 4rpx;


		font-weight: 400;
		font-size: 20rpx;
		color: #FFFFFF;

	}


	.cancelled {
		color: #f44336;
	}

	.card-content {
		width: 686rpx;
		min-height: 250rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 8rpx -2rpx rgba(0, 0, 0, 0.04), 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.03), 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.02);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 32rpx;
		margin-bottom: 20rpx;
	}

	.clinic {
		font-weight: bold;
		font-size: 28rpx;
		color: rgba(0, 0, 0, 0.85);


	}

	.name {

		font-weight: 400;
		font-size: 24rpx;
		color: rgba(0, 0, 0, 0.6);
		margin-bottom: 12rpx;

	}

	.time {

		font-weight: 400;
		font-size: 24rpx;
		color: rgba(0, 0, 0, 0.6);
		margin-bottom: 12rpx;


	}



	.appointment-info {
		margin-top: 20rpx;
	}
</style>